quadPlot <- function(fileName="CGPFUL",colorOn=FALSE,minfreq=0.0,ageGroup=5,generations=100)

#IO: Read Data
for(p in c(1:2)){

samples<-as.matrix(read.csv(paste(fileName,p,".dat",sep=""),header=FALSE,sep=" "))
x<-samples[,1]
y<-samples[,2]
Freq<-samples[,3]
Age<-samples[,4]

#Transform and filter frequencies

Freqv<-c(Freq)
Freqv<-ifelse((Freqv/max(Freqv))>minfreq,Freqv,0)
Freqv<-log10(Freqv+1)

#Transform ages and produce colors
Agev<-c(Age/Freq)

#Autoscaling
nonZeroFrequencies <- which(Freqv>0)
xbound = c(min(x[nonZeroFrequencies]),max(x[nonZeroFrequencies]))
ybound = c(min(y[nonZeroFrequencies]),max(y[nonZeroFrequencies]))

if(colorOn)
ageMap<-colormap(Agev,n=ageGroup,colFn=orangeblue)
else
ageMap<-colormap(Agev,n=ageGroup,colFn=greyscale)
end

ageColor<-num2col(Agev,ageMap)

#Plot
sTitle=paste("Population ",p,sep="")
print(sTitle)

windows()
keyPlus(ageMap,lab="Average Generation of state")
plot(x,y,cex=Freqv,col=ageColor,pch=19,xlim=xbound,ylim=ybound,main=sTitle)
dev.copy(png,paste(fileName,p,".png"))
dev.off()
windows()
keyPlus(ageMap,lab="Average Generation of state")
plot(x,y,cex=Freqv,col=ageColor,,xlim=xbound,ylim=ybound,main=sTitle)
dev.copy(png,paste(fileName,p,"_full.png"))
dev.off()
return

}